<?php
  /* ELABORO: KARYNA ROSALES BOTELLO */
  /* MODULO PARA CARGAR CATALOGOS. */
  INCLUDE "F_CONX.php";
  $V_NOMFILE="archivos\SCCATS.SEQ";
  CARGA_BDC($V_NOMFILE);
  CARGA_EDOS($V_NOMFILE);
  FUNCTION CARGA_BDC($P_NOMFILE)
  {
     //MYSQL_QUERY("TRUNCATE TABLE AREAS");
     $F_FILE=FOPEN($P_NOMFILE,'r');
	 WHILE(!FEOF($F_FILE))
     {
      $F_CAD     =  FGETS($F_FILE);
      $F_REG     =  SUBSTR($F_CAD, 0, 1);
      $F_CLAVE   =  SUBSTR($F_CAD, 1, 5);
      $F_NAME    =  SUBSTR($F_CAD,10,25);
      IF (($F_REG=='1') AND STRLEN(TRIM($F_CLAVE))==5 AND (STRSTR($F_NAME,"DIVISION ") OR STRSTR($F_NAME,"ZONA ")))
      {
         $MS_SQL    =  "INSERT INTO AREAS VALUES ('$F_CLAVE','$F_NAME')";
         $MS_RESULT =  MYSQL_QUERY ($MS_SQL);
      }
     }
     FCLOSE($F_FILE);
  }
  MYSQL_CLOSE($link);
  FUNCTION CARGA_EDOS($P_NOMFILE)
  {
    // MYSQL_QUERY("TRUNCATE TABLE EDOS");
     $F_FILE=FOPEN($P_NOMFILE,'r');
	 WHILE(!FEOF($F_FILE))
     {
      $F_CAD     =  FGETS($F_FILE);
      $F_REG     =  SUBSTR($F_CAD, 0, 1);
      $F_CLAVE   =  SUBSTR($F_CAD, 1, 1);
      $F_NAME    =  SUBSTR($F_CAD,10,30);
      $F_ABREV   =  SUBSTR($F_CAD,40, 5);
      IF ($F_REG=='4')
      {
         $MS_SQL    =  "INSERT INTO EDOS VALUES ('$F_CLAVE','$F_NAME','$F_ABREV')";
         $MS_RESULT =  MYSQL_QUERY ($MS_SQL);
      }
     }
     FCLOSE($F_FILE);
  }
?>
